package com.syaccp.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.syaccp.mapper.OrderOperRecordMapper;
import com.syaccp.model.OrderOperRecord;
import com.syaccp.service.OrderOperRecordService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 针对表【t_order_oper_record(订单操作记录表)】的数据库操作Service实现
 *
 * @author Lyh
 * @since 2023-07-23 08:25:43
 */
@Service
public class OrderOperRecordServiceImpl extends ServiceImpl<OrderOperRecordMapper, OrderOperRecord>
        implements OrderOperRecordService {

    @Resource
    OrderOperRecordMapper orderOperRecordMapper;

    @Override
    public List<OrderOperRecord> queryOrderRecordByOrderId(Integer orderId) {
        LambdaQueryWrapper<OrderOperRecord> lqw = Wrappers.lambdaQuery();
        lqw.eq(OrderOperRecord::getOrderId, orderId)
                .eq(OrderOperRecord::getStatus, 0)
                .orderByAsc(OrderOperRecord::getCreateTime);
        List<OrderOperRecord> orderRecordsList = orderOperRecordMapper.selectList(lqw);
        if (ObjectUtils.isNotEmpty(orderRecordsList))
            orderRecordsList.get(orderRecordsList.size() - 1).setColor("#016fff");
        return orderRecordsList;
    }

    @Override
    public Integer insertOrderRecord(OrderOperRecord orderOperRecord) {
        return orderOperRecordMapper.insert(orderOperRecord);
    }
}




